<?php
namespace app\api\model;

use think\Db;

/**
 * 充值查询
 *
 * @author wangjinxi
 *        
 */
class Recharge extends BaseModel {

    protected $table = 'recharge';

    public function insert($data) {
        return Db::name($this->table)->insertGetId($data);
    }

    public function getRechargeList($mid, $page = 1, $size = 10) {
        return Db::name($this->table)->where('type',1)//充值
            ->where('mid', $mid)
            ->page($page,$size)
            ->order('id','desc')
            ->select();
    }
    
    public function getRechargeListCount($mid) {
        return Db::name($this->table)->where('type', 1)//充值
        ->where('mid', $mid)
        ->count();
    }
    
    public function getWithdrawList($mid, $page = 1, $size = 10) {
        return Db::name($this->table)->where('type', 2)//提现
            ->where('mid', $mid)
            ->page($page,$size)
            ->order('id','desc')
            ->select();
    }
    
    public function getWithdrawListCount($mid) {
        return Db::name($this->table)->where('type', 2)//提现
        ->where('mid', $mid)
        ->count();
    }
    
    public function getById($mid,$id){
        return Db::name($this->table)->where('mid', $mid)->where('id', $id)->find();
    }

    
}